##cmake_minimum_required( VERSION 2.8 )
project("usldb plugin database mysql")
find_package( Qt4 REQUIRED )

ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ADD_DEFINITIONS(-DQT_SHARED)

include( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR}
    ${QT_QTSQL_INCLUDE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    ../../../core/interfaces/
)


set(INSTPREF ${CMAKE_INSTALL_PREFIX})
configure_file(../../../core/src/def.h.in def.h)
set( HEADERS
        src/libdb_mysql.h
        src/dbworker.h
        src/libdbmysql_data.h
	)
set( SOURCES 
        src/libdb_mysql.cpp
        src/dbworker.cpp
        src/libdbmysql_data.cpp
	)

set( UIS

)

qt4_wrap_ui(UIS_H ${UIS})

qt4_wrap_cpp(MOC ${HEADERS})

#set( RESOURCES res.qrc )
#qt4_add_resources( QRC_SOURCES ${RESOURCES} )

add_library(db_mysql SHARED ${SOURCES} ${MOC} ${UIS_H} ) #${QRC_SOURCES})

target_link_libraries(db_mysql ${QT_LIBRARIES} ${QT_QTSQL_LIBRARIES})

# install for linux
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
        set(rootdir ${CMAKE_INSTALL_PREFIX})
        set(libdir ${rootdir}/lib/usldb)
        set(rootdir_lang ${rootdir}/share/usldb/lang)
        install(TARGETS db_mysql DESTINATION ${libdir})
        install(FILES lang/ru.qm DESTINATION ${rootdir_lang}/libdb_mysql)
endif()

# install for mac
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
        set(rootdir ${CMAKE_INSTALL_PREFIX})
        set(libdir ${rootdir}/lib/usldb)
        set(rootdir_lang ${rootdir}/share/usldb/lang)
        install(TARGETS db_mysql DESTINATION ${libdir})
        install(FILES lang/ru.qm DESTINATION ${rootdir_lang}/libdb_mysql)
endif()
